package recursion.nowcoder.easy;

import java.util.Scanner;

/**
 * @author bruin_du
 * @description 斐波那契凤尾
 * https://www.nowcoder.com/questionTerminal/c0a4b917a15f40a49ca10532ab9019fb
 * @date 2022/5/30 23:17
 **/
public class FibonacciTail {
    public static void main(String[] args) {
        int[] arr = new int[100001];
        int a = 0,b = 1;
        for (int i = 1; i < arr.length; i++) {
            arr[i] = a + b;
            if(arr[i] / 1000000 != 0){
                arr[i] %= 1000000;
            }
            a = b;
            b = arr[i];
        }
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int n = in.nextInt();
            if(n < 29) {
                System.out.println(arr[n]);
            }else{
                System.out.printf("%06d\n",arr[n]);
            }
        }
    }
}
